import multiprocessing
import time


class ProcessTask(multiprocessing.Process):  # 进程任务类
	def __init__(self, **kwargs):
		super().__init__(name=kwargs.get('name'))
		self._delay = kwargs.get('delay')  # 设置进程的延迟时间
		self._count = kwargs.get('count')  # 设置循环的执行次数

	def run(self):  # 相当于进程中的主函数
		for num in range(self._count):
			print(f"【count = {num}】"
				  f"进程ID = {multiprocessing.current_process().pid}"
				  f"进程名称 = {multiprocessing.current_process().name}")
			time.sleep(self._delay)


def main():  # 主函数
	for item in range(4):  # 循环创建4个进程
		process = ProcessTask(name=f"业务处理进程--{item}", delay=1, count=10)
		process.start()


if __name__ == '__main__':
	main()
